<?php
namespace App\Http\Controllers\Map;

use App\Service\ShelfService;
use Illuminate\Http\Request;

class ShelfController extends BaseController
{
    //货架

    //列表
    public function index()
    {
        $res = ShelfService::index();
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson(0, '', $res['data']);
    }

    //新增货架
    public function add(Request $request)
    {
        $type = $request->post('type', 0);
        $res = ShelfService::add($type);
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson();
    }

    //修改
    public function modify(Request $request)
    {
        $id = $request->post('id', 0);
        $pas['title'] = $request->post('title', '');
        $res = ShelfService::modify($id, $pas);
        if ($res['code'] < 0) {
            return self::toJson(-2, $res['msg']);
        }
        return self::toJson(0, '', $res['data']);
    }
}